
package com.ami.kvm.jviewer.gui;

import com.ami.kvm.jviewer.JViewer;
import com.ami.kvm.jviewer.common.oem.IOEMManager;
import com.ami.kvm.jviewer.hid.USBMouseRep;
import com.ami.kvm.jviewer.jvvideo.JVVideo;
import com.ami.kvm.jviewer.kvmpkts.KVMClient;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.net.URL;
import javax.swing.JFrame;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;

public class WindowFrame extends JVFrame {
	private WindowMenu m_menu;
	private JVStatusBar m_status;
	public Macrows macrows;
	private JVToolBar toolbar;
	private String m_label;
	private Dimension frameDimension = null;
	private boolean resizeFrame = false;
	
	public WindowFrame() {
		setTitle(LocaleStrings.getString("C_1_JVF"));

		constructUserIf();
		setDefaultCloseOperation(0);
		this.frameDimension = JViewer.getMainFrame().getSize();

		if (JViewer.isStandalone()) {
			JViewer.getMainFrame().addWindowFocusListener(new WindowAdapter() {

				public void windowGainedFocus(WindowEvent paramAnonymousWindowEvent) {

					if ((JViewer.isjviewerapp()) || (JViewer.isStandAloneApp())) {
						if ((JViewer.getOEMFeatureStatus() & 0x200) != 512L) {

							JViewerApp.getInstance()
									.setInitClientLEDStatus(JViewerApp.getInstance().getClientKeyboardLEDStatus());
						}

						JViewerView.syncLEDFlag = false;
						JViewerView.Lost_focus_flag = false;
						if ((JViewerApp.getInstance().GetRedirectionState() != JViewerApp.REDIR_STOPPED)
								&& (JViewerApp.getInstance().GetRedirectionState() != JViewerApp.REDIR_STOPPING)) {
							if (JViewerApp.getInstance().getKVMClient() != null)
								JViewerApp.getInstance().getKVMClient().sendLEDRequest();
							if (JViewerApp.getInstance().getRCView()
									.GetUSBMouseMode() != USBMouseRep.INVALID_MOUSE_MODE)
								JViewerApp.getInstance().getRCView().USBsyncCursor(true);
							JViewerApp.getInstance().resetModifiers();
						}

						if (JViewerApp.getInstance().getResolutionChanged() == 1) {
							if (JViewerApp.getInstance().getVidClnt() != null)
								JViewerApp.getInstance().getVidClnt().setZoomOptionStatus();
							JViewerApp.getInstance().setResolutionChanged(0);
						}
						WindowFrame.this.getM_status().resetStatus();
					}
				}

				public void windowLostFocus(WindowEvent paramAnonymousWindowEvent) {
					if ((JViewer.isjviewerapp()) || (JViewer.isStandAloneApp())) {
						JViewerView.syncLEDFlag = true;
						JViewerView.Lost_focus_flag = true;
						WindowFrame.this.resizeFrame = true;
						if (JViewerApp.getInstance().GetRedirectionState() == JViewerApp.REDIR_STARTED)
							JViewerApp.getInstance().getRCView().USBsyncCursor(false);
						WindowFrame.this.frameDimension = JViewer.getMainFrame().getSize();
						if ((JViewer.getOEMFeatureStatus() & 0x200) != 512L) {

							JViewerApp.getInstance()
									.setClientKeyboardLEDStatus(JViewerApp.getInstance().getInitClientLEDStatus());

						}

					}

				}

			});
			JViewer.getMainFrame().addWindowListener(new WindowAdapter() {
				public void windowClosing(WindowEvent paramAnonymousWindowEvent) {
					WindowFrame.this.windowClosed();
				}
			});
		} else {
			addInternalFrameListener(new InternalFrameAdapter() {
				public void internalFrameActivated(InternalFrameEvent paramAnonymousInternalFrameEvent) {
					if (!JViewer.isStandalone())
						JViewer.getMainFrame().setJMenuBar(WindowFrame.this.m_menu.getMenuBar());
				}

				public void internalFrameClosing(InternalFrameEvent paramAnonymousInternalFrameEvent) {
					WindowFrame.this.windowClosed();
				}
			});
		}
	}

	public JVMenu getMenu() {
		return this.m_menu;
	}

	public void setStatus(String paramString) {
		this.m_status.setStatus(paramString);
	}

	public void resetStatus() {
		this.m_status.resetStatus();
	}

	public void exitApp() {
		windowClosed();
	}

	public void refreshTitle() {
		if (JViewerApp.getOEMManager().setWndFrameTitle(this.m_label) == 0) {
			if ((JViewer.isStandalone()) || (JViewer.isplayerapp())) {
				String str = JViewerApp.getInstance().getResolutionStatus();
				if (str != null) {
					JViewer.getMainFrame().setTitle(
							JViewer.getTitle() + " [" + m_serverIP + "] - " + "[ " + str + " ] - " + this.m_label);
				} else
					JViewer.getMainFrame().setTitle(JViewer.getTitle() + " [" + m_serverIP + "] - " + this.m_label);
			} else {
				setTitle(JViewer.getTitle() + " - " + m_serverIP + " - " + this.m_label);
			}
		}
	}

	public void setWndLabel(String paramString) {
		this.m_label = paramString;
		if (JViewerApp.getOEMManager().setWndFrameTitle(paramString) == 0) {
			if ((JViewer.isStandalone()) || (JViewer.isplayerapp())) {
				String str = JViewerApp.getInstance().getResolutionStatus();
				if (str != null) {
					JViewer.getMainFrame().setTitle(
							JViewer.getTitle() + " [" + m_serverIP + "] - " + "[ " + str + " ] - " + this.m_label);
				} else
					JViewer.getMainFrame().setTitle(JViewer.getTitle() + " [" + m_serverIP + "] - " + this.m_label);
			} else {
				setTitle(JViewer.getTitle() + " - " + m_serverIP + " - " + paramString);
			}
		}
	}

	private void constructUserIf() {
		Container localContainer = getContentPane();
		localContainer.removeAll();
		localContainer.setLayout(new BorderLayout());
		if (!JViewer.isdownloadapp()) {
			if (JViewer.isplayerapp()) {
				setToolbar(new RecorderToolBar());
				localContainer.add(RecorderToolBar.getPanel(), "Last");
			} else {
				this.m_menu = new WindowMenu();
				if (JViewer.isStandalone()) {
					setJMenuBar(this.m_menu.getMenuBar());
				} else {
					JViewer.getMainFrame().setJMenuBar(this.m_menu.getMenuBar());
					JViewer.getMainFrame().setVisible(true);
				}

				this.m_status = new JVStatusBar();
				this.macrows = new Macrows(this.m_status);
				localContainer.add(this.m_status.getStatusBar(), "Last");
				this.m_status.setStatus(LocaleStrings.getString("W_1_WF"));
				setToolbar(new JVToolBar());
			}
			localContainer.add(getToolbar().getToolBar(), "First");
		}
		if (JViewer.isStandalone()) {
			URL localURL = JViewer.class.getResource("res/jviewer.jpg");

			JViewer.getMainFrame().setIconImage(Toolkit.getDefaultToolkit().getImage(localURL));
		}
	}

	public JVStatusBar getM_status() {
		return this.m_status;
	}

	public void setM_status(JVStatusBar paramJVStatusBar) {
		this.m_status = paramJVStatusBar;
	}

	public WindowMenu getWindowMenu() {
		return this.m_menu;
	}

	public Dimension getFrameDimension() {
		return this.frameDimension;
	}

	public boolean isResizeFrame() {
		return this.resizeFrame;
	}

	public void setResizeFrame(boolean paramBoolean) {
		this.resizeFrame = paramBoolean;
	}

	public JVToolBar getToolbar() {
		return this.toolbar;
	}

	public void setToolbar(JVToolBar paramJVToolBar) {
		this.toolbar = paramJVToolBar;
	}
}

/*
 * Location:
 * D:\Users\tianlin\Downloads\JViewer.jar!\com\ami\kvm\jviewer\gui\WindowFrame.
 * class Java compiler version: 5 (49.0) JD-Core Version: 0.7.1
 */